package com.example.asuper.check.Helper;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.Toast;

/**
 * Created by Superb on 2016/2/27.
 */
public class SharePrefenceHelper {
    //写入信息
    public static boolean WriteSharedPreferences(String groupName,String key,String value,Context context) {
        try {
            SharedPreferences user = context.getSharedPreferences(groupName, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = user.edit();
            editor.putString(key, value);
            editor.commit();
        } catch (Exception e) {
            return false;
        }
        return true;
    }


    //读取信息
    public static String ReadSharedPreferences(String group,String key,Context context){
        try{
            String result;
            SharedPreferences   user =context.getSharedPreferences(group,Context.MODE_PRIVATE);
            result = user.getString(key,"");
            if (result!=null&&!result.equals("")){
                return result;
            }else {
                return "";
            }
        }catch (Exception e){
            return "";
        }
    }
}
